<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:c="http://java.sun.com/jsp/jstl/core"> 

	<ui:composition template="../template.xhtml">
		<ui:define name="conteudo">
			<p:ajaxStatus onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
			<p:dialog modal="true" widgetVar="statusDialog" header="Status"   
		        draggable="false" closable="false">  
			    <h:outputText value="Aguarde..." /> 
			</p:dialog>  
			<div id="location">Manter Usuário</div>
			<div id="container">
				<p:messages id="growl" showDetail="true" showSummary="false"/>
       			<div id="form">
       				<h:form id="usuarioForm">
       				<h:inputHidden value="#{usuarioMB.usuario.id}" />
       				<p:messages id="growl" showDetail="true" showSummary="false" />
       				<fieldset>
       					<fieldset>
       					<legend>Dados</legend>
       					<table width="80%" align="left">
       						<tr>
       							<td>
       								<label style="width: 200px;">
       									<p>Perfil:</p>
       									<h:selectOneMenu value="#{usuarioMB.usuario.idPerfil}" required="true" requiredMessage="Perfil é Obrigatório!">
       										<f:selectItem itemLabel="Selecione" itemValue=""/>
       										<f:selectItems value="#{usuarioMB.perfilList}" var="perf" itemValue="#{perf.id}" itemLabel="#{perf.nmPerfil}"/>
       									</h:selectOneMenu>
       								</label>
       							</td>
       							<td>
       								<label  style="width: 200px;">
			       						<p>Associação:</p>
			       						<h:selectOneMenu value="#{usuarioMB.usuario.idAssociacao}" required="false">
			       							<f:selectItem itemLabel="Selecione" itemValue=""/>
			       							<f:selectItems value="#{usuarioMB.associacaoList}" var="ass" itemLabel="#{ass.razaoSocial}" itemValue="#{ass.id}"/>
			       						</h:selectOneMenu>
			       					</label>
       							</td>
  								<td>
  									<label style="width: 200px;">
			       						<p>Nome:</p>
			       						<p:inputText value="#{usuarioMB.usuario.nmUsuario}" required="true" requiredMessage="Nome é obrigatório"/>
			       					</label>
  								</td>
  								<td>
  									<label style="width: 100px;">
			       						<p>login:</p>
			       						<p:inputText value="#{usuarioMB.usuario.dsLogin}" required="true" requiredMessage="Login é obrigatório"/>
			       					</label>
  								</td>
  								<td>
  									<label style="width: 100px;">
			       						<p>Senha:</p>
			       						<p:inputText feedback="false" value="#{usuarioMB.usuario.senha}" required="true" requiredMessage="Senha é obrigatória!"/>
			       					</label>
  								</td>
  							</tr>
       					</table>
       				</fieldset>
       				<p:spacer height="20"/>
       				<div align="right" style="padding-right: 20px; padding-bottom: 10px;">
       					<p:commandButton value="Salvar" action="#{usuarioMB.saveOrUpdate}" update="form growl"/>
       					<p:spacer width="10"/>
       					<p:commandButton value="Voltar" ajax="false" action="#{usuarioMB.paginaBusca}" immediate="true"/>
       				</div>
       				</fieldset>
       				</h:form>
       			</div>
       		</div>	
		</ui:define>
	</ui:composition>
</html>